using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;

namespace RabbitTraceability.Api.Filters
{
    /// <summary>
    /// 过滤器扩展方法
    /// </summary>
    public static class FilterExtensions
    {
        /// <summary>
        /// 添加全局过滤器
        /// </summary>
        /// <param name="services">服务集合</param>
        /// <returns>服务集合</returns>
        public static IServiceCollection AddGlobalFilters(this IServiceCollection services)
        {
            services.AddControllers(options =>
            {
                // 添加全局异常过滤器
                options.Filters.Add<GlobalExceptionFilter>();
                
                // 添加日志记录过滤器
                options.Filters.Add<LoggingActionFilter>();
            });
            
            return services;
        }
    }
} 